(function() {

    'use strict';

    angular
        .module('app')
        .controller('VideoController', VideoController);

    VideoController.$inject = ['$scope', '$state', '$stateParams', 'API', '$window'];

    function VideoController($scope, $state, $stateParams, API, $window) {

        var pig_id = $stateParams.pig_id;
        $scope.loading = false;
        $scope.loaded = false;
        $scope.live_url = '';

        $scope.reload = _reload;

        _reload();

        function _reload() {
            if ($scope.loading) {
                return;
            }

            API.presales.getLiveUrl({pig_id:pig_id}).then(function (res) {
                if (res) {
                    $scope.live_url = res;
                    $scope.loading = false;
                    $scope.loaded = true;
                }
            });
        }


    }

})();